#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> threeSum(vector<int> &nums)
{
    vector<vector<int>> res;
    sort(nums.begin(), nums.end());
    int n = nums.size();
    for (int i = 0; i < n - 2; i++)
    {
        if (i >= 1 && nums[i - 1] == nums[i])
        {
            continue;
        }
        int r = n - 1;
        int target = -nums[i];
        for (int j = i + 1; j < n - 1; j++)
        {
            if (j > i + 1 && nums[j - 1] == nums[j])
            {
                continue;
            }
            while (j < r && nums[j] + nums[r] > target)
            {
                r--;
            }
            if (r == j)
                break;
            if (nums[r] + nums[j] == target)
            {
                res.push_back({nums[i], nums[j], nums[r]});
            }
        }
    }
    return res;
}
int main()
{
    int n;
    cin >> n;
    vector<int> num(n);
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }
    vector<vector<int>> res = threeSum(num);
    for (auto &v : res)
    {
        for (auto &i : v)
        {
            cout << i << " ";
        }
        cout << endl;
    }
    return 0;
}